#include "ListIDContainer.h"

ListIDContainer::ListIDContainer()
{
	
}

ListIDContainer::~ListIDContainer()
{
	
}

ListIDContainer::ListIDContainer(const ListIDContainer& )
{
	
}

bool ListIDContainer::getID( RawObjectData* raw, unsigned int& refID )
{
	map<RawObjectData*,unsigned int>::iterator it = _idMap.find(raw);
	
	if( it == _idMap.end() )
	{				
		int maxMeshes = raw->getMeshes()->size();
		int id = glGenLists(maxMeshes);
		_idMap.insert( pair<RawObjectData*,unsigned int>( raw , id ) );
		refID = id;
		return false;
	}

	refID = it->second;
	return true;
}

void ListIDContainer::delID( RawObjectData* raw )
{
	map<RawObjectData*,unsigned int>::iterator it = _idMap.find(raw);
	
	if( it != _idMap.end() )
	{
		int maxMeshes = raw->getMeshes()->size();
		glDeleteLists( it->second,maxMeshes);
		_idMap.erase(it);
	}
};

